<?php 
	Class Car extends CI_Controller{
		public function __construct(){
			parent::__construct();
			$this->load->model("model_car");	
			$this->load->model("model_carbanner");	
			$this->load->model("model_restaurant");	
			$this->load->model("model_activity");	
			$this->load->model("model_package");	
			$this->load->model("model_flight");
			$this->load->model("model_guild");
		}	
		
		public function search(){
		    if(isset($_GET["type"]) && isset($_GET["provide"]) && isset($_GET['service'])){
				$data['data']=$this->model_car->listallby_search($_GET["provide"],$_GET["type"],$_GET["service"],10,0);
				$data['total']=$this->model_car->listallby_search($_GET["provide"],$_GET["type"],$_GET["service"],10000000,0);
			}	
			
			foreach($data['data'] as $list){
				$data['listbanner']=$this->model_carbanner->gettopbanner_search($list['id']);
			}
			
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($_GET['provide'],0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($_GET['provide'],0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='car/car_search';
			$this->load->view('layout',$data);
		}
		
		public function detail($idcar){
			$data['idcar']=intval($idcar);
			$data['detail']=$this->model_car->getdata(intval($idcar));
			$data['banner']=$this->model_carbanner->getallbycarid($idcar);
			
			
			$data["restaurant"]=$this->model_restaurant->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["activities"]=$this->model_activity->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["package"]=$this->model_package->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["flight"]=$this->model_flight->gettopByprovide_status($_GET['provide'],0,6,0);
			$data["car"]=$this->model_car->gettopByprovide_status($_GET['provide'],0,3,0);
			$data["guide"]=$this->model_guild->gettopByprovide_status($_GET['provide'],0,3,0);
			$data['listname_restaurant']=$this->model_restaurant->listall_name();
			
			$data['template']='car/detail';
			$this->load->view('layout',$data);
		}
	}
?>